package com.ruoyi.hualian.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.hualian.domain.HlOtherCommodity;
import com.ruoyi.hualian.service.IHlOtherCommodityService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 其他型号Controller
 * 
 * @author hujian
 */
@RestController
@RequestMapping("/hualian/commodity")
public class HlOtherCommodityController extends BaseController
{
    @Autowired
    private IHlOtherCommodityService hlOtherCommodityService;

    /**
     * 查询其他型号列表
     */
    @PreAuthorize("@ss.hasPermi('hualian:commodity:list')")
    @GetMapping("/list")
    public TableDataInfo list(HlOtherCommodity hlOtherCommodity)
    {
        startPage();
        List<HlOtherCommodity> list = hlOtherCommodityService.selectHlOtherCommodityList(hlOtherCommodity);
        return getDataTable(list);
    }

    /**
     * 导出其他型号列表
     */
    @PreAuthorize("@ss.hasPermi('hualian:commodity:export')")
    @Log(title = "其他型号", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HlOtherCommodity hlOtherCommodity)
    {
        List<HlOtherCommodity> list = hlOtherCommodityService.selectHlOtherCommodityList(hlOtherCommodity);
        ExcelUtil<HlOtherCommodity> util = new ExcelUtil<HlOtherCommodity>(HlOtherCommodity.class);
        util.exportExcel(response, list, "其他型号数据");
    }

    /**
     * 获取其他型号详细信息
     */
    @PreAuthorize("@ss.hasPermi('hualian:commodity:query')")
    @GetMapping(value = "/{otherId}")
    public AjaxResult getInfo(@PathVariable("otherId") Long otherId)
    {
        return success(hlOtherCommodityService.selectHlOtherCommodityByOtherId(otherId));
    }

    /**
     * 新增其他型号
     */
    @PreAuthorize("@ss.hasPermi('hualian:commodity:add')")
    @Log(title = "其他型号", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HlOtherCommodity hlOtherCommodity)
    {
        return toAjax(hlOtherCommodityService.insertHlOtherCommodity(hlOtherCommodity));
    }

    /**
     * 修改其他型号
     */
    @PreAuthorize("@ss.hasPermi('hualian:commodity:edit')")
    @Log(title = "其他型号", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HlOtherCommodity hlOtherCommodity)
    {
        return toAjax(hlOtherCommodityService.updateHlOtherCommodity(hlOtherCommodity));
    }

    /**
     * 删除其他型号
     */
    @PreAuthorize("@ss.hasPermi('hualian:commodity:remove')")
    @Log(title = "其他型号", businessType = BusinessType.DELETE)
	@DeleteMapping("/{otherIds}")
    public AjaxResult remove(@PathVariable Long[] otherIds)
    {
        return toAjax(hlOtherCommodityService.deleteHlOtherCommodityByOtherIds(otherIds));
    }
}
